<?php
require_once 'util/class.dbservice.php';

class AdviceDao {
	
	 public function addAdvice($id, $userId, $content, $timestamp) {
	 	try {
	 		$collection = $this->getCollection();
	 		if(!$collection)
	 			return;
	 		
	 		$collection->insert(array('_id'=>$id, 'uid'=>$userId, 'text'=>$content,'ts'=>$timestamp));
	 	} catch(Exception $e) {
	 		syslog(LOG_ERR, "AdviceDao.addAdvice error, reason=".$e);
	 	}
	 }
	 
	 private function getCollection() {
	 	$db=DBService::getGlobalDb();
	 	return $db->advice;
	 }
}